package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.advertlaunch.AdvertLaunchBO;
import com.micro.modual.model.dto.advertlaunch.AdvertLaunchDetailDTO;
import com.micro.modual.model.dto.advertlaunch.AdvertLaunchListDTO;
import com.micro.modual.service.AdvertLaunchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>广告基础表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "广告管理",tags = "广告管理")
@RestController
@RequestMapping(value = "advertLaunch")
public class AdvertLaunchController {

    @Autowired
    private AdvertLaunchService advertLaunchService;

    /**
     * <h2>查找广告基础表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<AdvertLaunchListDTO> {@link AdvertLaunchListDTO}s  广告基础表 列表返回对象
     */
    @ApiOperation(value = "查询广告列表" ,notes = "查询广告列表")
    @GetMapping(value = "/findAdvertLaunchList")
    public RespJsonPageData<AdvertLaunchListDTO> findAdvertLaunchList(@RequestParam  Map<String,Object> params){
        return advertLaunchService.findList(params,AdvertLaunchListDTO.class);
    }

    /**
     * <h2>根据主键编号查看广告基础表详情</h2>
     * @param id  广告基础表 主键编号
     * @return {@link AdvertLaunchDetailDTO}  广告基础表 详情
     */
    @ApiOperation(value = "查询广告基础表详情",notes = "根据主键编号，查询广告基础表详情")
    @GetMapping(value = "/findAdvertLaunchDetail/{id}")
    public RespJsonData<AdvertLaunchDetailDTO> findAdvertLaunchDetail(@PathVariable("id") Long id){
        return advertLaunchService.findDetail(id,AdvertLaunchDetailDTO.class);
    }

    /**
     * <h2>新增广告基础表详情</h2>
     * @param advertLaunchBO {@link AdvertLaunchBO} 广告基础表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增广告基础表",notes = "新增广告基础表")
    @PostMapping(value = "/addAdvertLaunch")
    public RespJson addAdvertLaunch(@RequestBody AdvertLaunchBO advertLaunchBO){
        return advertLaunchService.addAdvertLaunch(advertLaunchBO);
    }

    /**
     * <h2>修改广告基础表详情</h2>
     * @param advertLaunchBO  {@link AdvertLaunchBO} 广告基础表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改广告基础表",notes = "修改广告基础表")
    @PostMapping(value = "/editAdvertLaunch")
    public RespJson editAdvertLaunch(@RequestBody AdvertLaunchBO advertLaunchBO){
        return advertLaunchService.editAdvertLaunch(advertLaunchBO);
    }

    /**
     * <h2>根据主键编号删除广告基础表信息</h2>
     * @param id  广告基础表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除广告基础表",notes = "根据地址ID，删除广告基础表")
    @PostMapping(value = "/deleteAdvertLaunch/{id}")
    public RespJson deleteAdvertLaunch(@PathVariable("id") Long id){
        return advertLaunchService.deleteAdvertLaunch(id);
    }
}

